import React from "react";
import { useSelector } from "react-redux";
import { Redirect, Route } from "react-router";
import { getToken } from "../features/user/slice";
import Login from "../pages/Login";

const LoginRoute = () => {
  let token = useSelector(getToken);
  return token ? (
    <Redirect to="/main" />
  ) : (
    <Route path="/login">
      <Login />
    </Route>
  );
};

export default LoginRoute;
